package com.kuzan.autocloud.common.model.log;

import com.kuzan.autocloud.common.model.Base;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;

/**
 * <p>Description: 记录修改历史</p>
 *
 * @author kuzank
 */
@Data
@NoArgsConstructor
@Entity
@Table(name = "sys_log_record_history")
public class LogRecordHistory extends Base {
    /**
     * 日志类型
     */
    @Column(length = 32)
    private String logtype;
    /**
     * 日志正式记录ID
     */
    @Column(length = 32)
    private String official;
    /**
     * 目标表
     */
    @Column(length = 32)
    private String target;
    /**
     * 字段ID
     */
    @Column(length = 32)
    private String field;
    /**
     * 记录ID
     */
    @Column(length = 32)
    private String obj;
    /**
     * 上一次值
     */
    private String prevalue;
    /**
     * 修改后值
     */
    private String aftervalue;

    public static LogRecordHistory ofCreate(String creator, String dateoflog, String logtype, String official, String target, String field, String obj, String content, String prevalue) {
        LogRecordHistory log = new LogRecordHistory();
        log.setLogtype(logtype);
        log.setOfficial(official);
        log.setTarget(target);
        log.setField(field);
        log.setObj(obj);
        log.setAftervalue(content);
        log.setPrevalue(prevalue);
        log.setCreator(creator);
        log.setCreatetime(dateoflog);
        log.setUpdatetime(dateoflog);
        return log;
    }

}
